package com.ys.basebindinggdemo

import android.widget.Toast
import androidx.activity.addCallback
import com.ys.basebindinggdemo.databinding.ActivityMainBinding
import com.ys.basebindinggdemo.ui.base.BaseViewModel
import com.ys.lib.android.base.BaseActivity
import kotlin.system.exitProcess

class MainActivity : BaseActivity<ActivityMainBinding,BaseViewModel>() {

    private var clickBackTime=System.currentTimeMillis()
    override fun init() {
        onBackPressedDispatcher.addCallback{
            if (System.currentTimeMillis()-clickBackTime<2000){
                exitProcess(0)
            }else{
                Toast.makeText(applicationContext,"再次点击退出程序",Toast.LENGTH_SHORT).show()
                clickBackTime=System.currentTimeMillis()
            }

        }
    }

}